﻿@model PinBoardCreateViewModel

@{
    Layout = null;
}

<form method="post" action="/PinBoard/Create" id="theForm">

    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

        <div class="form-group">
            <div class="col-md-12" style="margin-top:3%;">
                @*<label class="tahomaFont">عنوان</label>*@
                
                <input type="text" class="form-control tahomaFont" id="boardTitle" placeholder="عنوان برد" required
                        name="title" style="width:95%; margin-left:auto; margin-right:auto; ">

                <div class="has-warning" style="width:80%; margin-left:auto; margin-right: auto;">
                    <label class="control-label" for="inputWarning">توضیحات</label>
                    <div class="input-icon right">
                        <i class="fa fa-info-circle tooltips" 
                           data-original-title="لطفاً توضیحات رو وارد کن" data-container="body"></i>
                        <input type="text" class="form-control" name="description" required>
                    </div>
                </div>
                <select class="form-control" style="margin-top: 2%; width:70%; margin-left:auto; margin-right: auto;" name="CategoryId">
                    @foreach(var item in this.Model.Categories)
                    {
                        <option value="@item.Id">@item.Title</option>
                    }
                </select>
            </div>
        </div>


        <div class="form-actions top fluid ">
            <div class="col-md-offset-3 col-md-9">
                
                <button type="submit" class="btn green" style="float:left;"><i class="fa fa-check"></i> ثبت</button>
            </div>
        </div>

       
    </div>
</form>
<script>
    $('#theForm').submit(function (e) {
        e.preventDefault();
        
        if ($('#boardTitle').val() == '') {
            return;
        }

        var form = $(this);
        $.ajax({
            type: 'post',
            url: form.attr('action'),
            data: form.serialize(),
            beforeSend: function () {
                App.blockUI(form);
            },
            error: function () {
                App.unblockUI(form);
                toastrHelper.error('خطا', '');
            },
            success: function (data) {
                toastrHelper.success('پیام', 'ثبت شد');
                App.unblockUI(form);
            }
        });
        
    });
</script>

